<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #div1 {
            width: 150px;
            height: 150px;
            background-color: blueviolet;
        }

        #div2 {
            width: 150px;
            height: 150px;
            background-color: green;
        }
    </style>
</head>

<body>
    <div id="div1">
        111
    </div>
    <div id="div2">
        222
    </div>
    <script>
        const div1Obj = document.querySelector("#div1");
        const div2Obj = document.querySelector("#div2");
        div1Obj.onclick = function () {
            // div1Obj.style.backgroundColor = "red";
            // div1Obj.style.height = "250px";
            // div1Obj.style.width = "250px";

            // this:指向当前对象
            this.style.backgroundColor = "blue";
            this.style.height = "300px";
            this.style.width = "350px";
        }
        div2Obj.onclick = function () {
            // div1Obj.style.backgroundColor = "red";
            // div1Obj.style.height = "250px";
            // div1Obj.style.width = "250px";

            // this:指向当前对象
            this.style.backgroundColor = "red";
            this.style.height = "300px";
            this.style.width = "350px";
        }
    </script>
</body>

</html>